package com.cxm.qyyz;

import android.text.TextUtils;

import com.cxm.qyyz.app.Constants;
import com.cxm.qyyz.entity.response.LoginEntity;
import com.luck.picture.lib.tools.SPUtils;


public class UserManager {

    private static UserManager mInstance;
    private LoginEntity user;

    private UserManager() {
        if (user == null) {
            user = new LoginEntity();
        }
    }

    public synchronized static UserManager getInstance() {
        if (mInstance == null) {
            String json = SPUtils.getInstance().getString(Constants.USER_INFO, "");
            if (mInstance == null) {
                mInstance = new UserManager();
            }
        }
        return mInstance;
    }

    public String getToken() {
        return user.getToken();
    }

    public LoginEntity getUser() {
        return user;
    }

    public boolean isLogin() {
        return !TextUtils.isEmpty(user.getToken());
    }

    public boolean isPaid() {
        if (user != null) {
            LoginEntity.AccountVoBean userAccount = user.getAccountVo();
            if (userAccount != null) {
                if (1 == userAccount.getIsCheckNotice()) {
                    return true;
                }
            }
        }
        return false;
    }
}
